<?php
$hasError = isset($_SESSION['has_error']) ? $_SESSION['has_error'] : false;
$errorBag = isset($_SESSION['error_bag']) ? $_SESSION['error_bag'] : ['error' => ''];

// 销毁session中的错误数据包 （错误数据包是一次性的）
if (isset($_SESSION['has_error']) && isset($_SESSION['error_bag'])) {
   unset($_SESSION['has_error']);
   unset($_SESSION['error_bag']);
}
?>

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>留言板-登录</title>
  <link rel="stylesheet" type="text/css" href="<?php echo assets('css/form.css')?>">
</head>
<body>
  <div id="wrapper">
    <form method="post" action="<?php echo url('signin_action')?>">
      <div class="row">
        <div class="input-box">
          <label>用户名</label>
          <input type="text" name="username" placeholder="请输入用户名">
        </div>
        <div class="error">
          <?php if($hasError) echo $errorBag['error'] ?>
        </div>
      </div>
      <div class="row">
        <div class="input-box">
          <label>密&nbsp;&nbsp;&nbsp;&nbsp;码</label>
          <input type="password" name="password" placeholder="请输入密码">
        </div>
      </div>
      <div class="input-box">
        <label>验证码</label>
        <input type="text" name="code"/>
      </div>
      <img src="../action/code/code.php">
        <div class="error">
          <?php if (isset($_SESSION['code_error'])) echo $_SESSION['code_error'] ?>
          <?php unset($_SESSION['code_error'])?>
        </div>
        <div class="row" style="height: 30px; line-height: 30px;">
           <div  style="width:400px; margin:0 auto; text-align: left;font-size: 14px;color:#222;">
           <input type="checkbox" id="remember-me" name="remember-me" value="1">
           <label for="remember-me">记住我</label>
          </div>
        </div>
      <div class="row">
          <button class="btn-large">登录</button>
      </div>
      <div class="info">
        还没有账号？现在<a href="<?php echo url('register')?>">注册</a>
      </div>
    </form>
  </div>
</body>
</html>